import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.image.ImageObserver;
import java.awt.image.ImageProducer;
import java.io.File;
import java.io.IOException;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-03-20
 * Time:16:02
 */
public class SimpleAnimation {
    int x=0;
    int y=0;

    public static void main(String[] args) {
        SimpleAnimation fw=new SimpleAnimation();
            fw.go();
    }
    public void go()
    {
        JFrame frame=new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MyDrawPane1 fw=new MyDrawPane1();
        frame.getContentPane().add(fw);
        frame.setSize(620,410);
        frame.setVisible(true);
        while(true)
        {   if(y==410)
        {
            x=0;y=0;
        }
            x++;y++;
            fw.repaint();
            try{
                Thread.sleep(10);
            }catch(Exception ex){}
        }
    }
    class MyDrawPane1 extends JPanel{
        public void paintComponent(Graphics g)
        {
            Image image=null;
            try {
                image= ImageIO.read(new File("D:\\code\\java\\Text3_20\\src\\123.jpg"));
            } catch (IOException e) {
                throw new RuntimeException(e);

            }
            g.drawImage(image,0,0,this);
            g.setColor(Color.red);

            //g.fillRect(0,0,this.getWidth(),this.getHeight());
            Color ee=new Color(200,180,190);
            //g.setColor(Color.BLACK);
            g.fillOval(x,y,10,10);

        }

    }
}
